uniform sampler2D	normalsSampler;
uniform float		specularPower;

varying vec2 texCoords;
varying vec3 t, b, n;

void main()
{

	// compute matrix that converts from tangent space to eye space
	mat3 tspacemat	= mat3(normalize(t), normalize(b), normalize(n));
	
	// lookup normal from normal map
	vec3 nSample = 2.0 * texture2D(normalsSampler, texCoords).rgb - 1.0;
	
	// convert normal to eye space
	vec3 eyeNormal = tspacemat * nSample;
	
	// pack normal into RGB, specular power into A
	gl_FragColor = vec4(0.5 + 0.5 * eyeNormal, specularPower / 300.0);
	
}